<?php
namespace app\index\listener;

use think\facade\Db;

class User
{
    public function handle($data)
    {
        $data->user_ip = request()->ip();
        $ws = app('think\swoole\Websocket');
        $field = Db::name('admin_user')->where('id', $data->admin_user_id)->value('field');
        if ($field) {
            $field = json_decode($field, true);
            if (isset($field['customer_fd'])) {
                $ws->to($field['customer_fd'])->emit('userMessage', $data);
            }
        }
    }
}